class PrintOwing {
	constructor(clock, console) {
		this._clock = clock;
		this._console = console;
	}

	printOwing(invoice) {
		let outstanding = 0;
		this._console.log('***********************');
		this._console.log('**** Customer Owes ****');
		this._console.log('***********************');
		// calculate outstanding
		for (const o of invoice.orders) {
			outstanding += o.amount;
		}
		// record due date
		const today = this._clock.today;
		invoice.dueDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 30);
		//print details
		this._console.log(`name: ${invoice.customer}`);
		this._console.log(`amount: ${outstanding}`);
		this._console.log(`due: ${invoice.dueDate.toLocaleDateString()}`);
	}
}

module.exports = PrintOwing;
